<template>
  <div class="dispatchlist">
    <el-form
      :inline="true"
      :model="SelOrderDTO"
      ref="SelOrderDTO"
      class="demo-form-inline"
    >
      <el-form-item
        label="导游姓名"
        style="width: 30%"
        label-width="100px"
      >
        <el-input
          v-model="SelOrderDTO.userName"
          placeholder="请输入内容"
          clearable
        ></el-input>
      </el-form-item>
      <el-form-item label="导游工号" style="width: 30%" label-width="100px" prop="userNumber"
        :rules="[
          { required: true, message: '内容不能为空' },
          { type: 'number', message: '内容必须为数字值' },
        ]">
        <el-input
          v-model.number="SelOrderDTO.userNumber"
          placeholder="请输入内容"
          autocomplete="off"
          clearable
        ></el-input>
      </el-form-item>
      <el-form-item label="派遣单号" style="width: 30%" label-width="100px">
        <el-input
          v-model="SelOrderDTO.orderNum"
          placeholder="请输入内容"
          clearable
        ></el-input>
      </el-form-item>
      <el-form-item label="订单时间" label-width="100px">
        <div class="block">
          <el-date-picker
            v-model="SelOrderDTO.orderDate"
            value-format="yyyy-MM-dd"
            format="yyyy-MM-dd"
            type="daterange"
            placement="bottom-end"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </div>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="queryDispatchFun">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="dispatchInfo"
      border
      style="width: 100%"
      :header-cell-style="{ textAlign: 'center' }"
      :cell-style="{ textAlign: 'center' }"
    >
      <el-table-column type="index" label="序号" width="50"> </el-table-column>
      <el-table-column prop="orderNum" label="派遣单号" width="301">
      </el-table-column>
      <el-table-column prop="orderDate" label="派遣单日期" width="200">
      </el-table-column>
      <el-table-column prop="orderStates" label="派遣单状态" width="120">
      </el-table-column>
      <el-table-column prop="orderType" label="派遣单类型" width="120">
      </el-table-column>
      <el-table-column prop="userName" label="导游姓名" width="120">
      </el-table-column>
      <el-table-column prop="userNumber" label="导游工号" width="120">
      </el-table-column>
      <el-table-column prop="personNum" label="游客人数" width="120">
      </el-table-column>
      <el-table-column prop="sumMoney" label="总价" width="120">
      </el-table-column>
    </el-table>

    <div class="pagination">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="SelOrderDTO.currentPage"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="SelOrderDTO.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totals"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { dispatchquery } from "@network/api/order.js";
export default {
  data() {
    return {
      SelOrderDTO: {
        currentPage: 1,
        pageSize: 5,
        orderDate: [],
        orderNum: "",
        userName: "",
        userNumber: "",
      },
      dispatchInfo: [],
      totals: 0,
    };
  },
  methods: {
    async dispatchList() {
      let resdispatchquery = await dispatchquery(this.SelOrderDTO);
      console.log("resdispatchquery", resdispatchquery);
      let { data } = resdispatchquery.data;
      this.dispatchInfo = data.orderList;
      this.totals = data.total;
    },
    queryDispatchFun() {
      this.dispatchList();
    },
    handleSizeChange(val) {
      this.SelOrderDTO.currentPage = 1;
      this.SelOrderDTO.pageSize = val;
      this.dispatchList();
    },
    handleCurrentChange(val) {
      this.SelOrderDTO.currentPage = val;
      this.dispatchList();
    },
  },
  created() {
    this.dispatchList();
  },
};
</script>

<style>
.dispatchlist {
  background-color: #fff;
  padding: 40px 20px;
}
.pagination {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}
</style>